SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE PROCEDURE dbo.[DnnProduct_GetServices]
	@PortalId  int,
	@UserId    int

AS
	SELECT     
		R.*,
		UR.IsOwner, 
		UR.UserRoleID, 
		UR.UserID, 
		UR.ExpiryDate, 
		UR.IsTrialUsed, 
		UR.EffectiveDate, 
		U.DisplayName, 
		U.Email
	FROM dbo.DnnProduct_Users U 
		INNER JOIN dbo.DnnProduct_UserRoles AS UR ON U.UserID = UR.UserID 
		RIGHT OUTER JOIN dbo.DnnProduct_Roles AS R ON UR.RoleID = R.RoleID AND UR.UserID = @UserId
	WHERE  R.PortalId = @PortalId AND R.IsPublic = 1
	ORDER BY R.RoleName

GO
